package com.my.yyr.security;

public class Result {
	
	public static Result success() {
		return new Result(true,null,null);
	}
	
	public static Result success(String message) {
		return new Result(true,message,null);
	}
	
	public static Result success(String message, Object data) {
		return new Result(true,message,data);
	}
	
	public static Result fail() {
		return new Result(false,null,null);
	}
	
	public static Result fail(String message) {
		return new Result(false,message,null);
	}
	
	public static Result fail(String message, Object data) {
		return new Result(false,null,data);
	}

	public static Result unLogined(){
		return new Result();
	}

	public static Result unAuthorized(){
		return new Result(true);
	}
	
	private boolean success;
	private String message;
	private Object data;

	private boolean logined;//是否已登录
	private boolean authorized;//是否已授权

	private  Result(){
		this.logined = false;
		this.authorized = false;
	}

	private Result(boolean logined){
		this.logined=logined;
		this.authorized = false;
	}
	
	private Result(boolean success, String message, Object data) {
		this.success=success;
		this.message=message;
		this.data=data;
		this.logined=true;
		this.authorized=true;
	}

	public boolean isSuccess() {
		return success;
	}

	public String getMessage() {
		return message;
	}

	public Object getData() {
		return data;
	}

	public boolean isLogined() {
		return logined;
	}

	public boolean isAuthorized() {
		return authorized;
	}
}
